<?php
session_start();

$row_add = ",`param_1`, `param_3`, `param_4`, `lev_1`, `lev_2`, `lev_3`, `lev_4`, `free_param`, `gan_lev_1`, `gan_lev_2`, `gan_lev_3`, `gan_lev_4`, `gan_lev_5`, `gan_lev_6`  ";

include ("func/func.php");

/**
 * if (!isset($_SESSION['uin']))
 * {
 *     mysql_close();
 *     header("location: index.php");
 *     exit('not log');
 * }
 */

include ("func/lvl.dco");
include ("func/lvl_p.dco");
include ("func/lvl_d.dco");
include ("func/gren_lev.dco");
?>
<!--
      <A href="pers_resou.php">• Ресурсы</A>
      <A href="workshop.php">• Мастерская</A>
      <A href="pers_param.php">• Управление параметрами</A> 
      <A href="pers_refer.php">• Рефер</A>
      <A href="pers_enemys.php">• Список врагов</A> 
      <A href="log_crimes.php?uin=<?php
echo $row['uin'];
?>">• Правонарушений</A> 
-->
<?php
//недвига
if (mysql_result(mysql_query("SELECT count(*) FROM geo.realty WHERE uin = $row[uin]"), 0) != 0) echo '<A href="pers_realty.php">• <b>Недвижимость</b></A>';

// реальный баблос
if ($row['money_2'] > 0) echo "<BR><B>&#163;</B>" . number_format($row['money_2'], 0, '.', '`');

//свободные параметры
if ($row['free_param'] > 0)
{
    echo $row['free_param'];
}

/* Job */
$res = mysql_query("SELECT geo.tipe.name, geo.realty.id FROM geo.tipe RIGHT JOIN geo.realty ON geo.tipe.tipe = geo.realty.tipe RIGHT JOIN geo.job ON geo.realty.id = geo.job.id WHERE geo.job.uin = $row[uin]");

if ($real = mysql_fetch_row($res))
{
    echo "<a href='info_realty.php?id=$real[1]'>$real[0]</a>";
} else
{
    $res = mysql_query("SELECT geo.tipe.name, geo.realty.id FROM geo.tipe RIGHT JOIN geo.realty ON geo.tipe.tipe = geo.realty.tipe  RIGHT JOIN geo.uin ON geo.realty.id = geo.uin.pos_job WHERE geo.uin.uin = $row[uin]");
    echo '<a href="info_realty.php?id=' . @mysql_result($res, 0, 1) . '">' . @mysql_result($res, 0) . '</a>';
}

if ($pos_job[0] = @mysql_result(mysql_query("SELECT time_ FROM geo.job where uin = $row[uin]"), 0))
{
    $pos_job[0] = ceil(($pos_job[0] - time()) / 60);
} else
{
    $pos_job[0] = '<!-- -||-  -->';
}
echo $pos_job[0];

//кланы
$res = mysql_query("SELECT geo.klans.name, geo.klans.id, geo.klans.tipe,  geo.klans.money, geo.uin.nick,  geo.uin.lev_1 FROM geo.klans RIGHT JOIN geo.klans_p ON geo.klans.id = geo.klans_p.id RIGHT JOIN geo.uin ON geo.uin.uin = geo.klans.uin WHERE geo.klans_p.uin = $row[uin] AND geo.klans_p.p_in = 0");

if ($klans = mysql_fetch_assoc($res))
{
    $tipe[0][1] = 'klan';
    $tipe[0][2] = 'corporation';
    $tipe[0][3] = 'community';
    $tipe[1][1] = 'клан';
    $tipe[1][2] = 'корпорация';
    $tipe[1][3] = 'Сообщество';

    while ($klans)
    {
        echo "Тип: " . $tipe[1][$klans[tipe]] . "\n" . "Владелец: " . $klans[nick] . "[" . lvl_p(1, $klans['lev_1']) . ']" href="' . $tipe[0][$klans[tipe]] . '.php?id=' . $klans['id'] . '">' . $klans['name'] . '</a>';
        echo '<a href="pers_klans.php?id=' . $klans['id'] . '&act=ent">Вступить</a>';
        echo '<a href="pers_klans.php?id=' . $klans['id'] . '&act=ex">Отказаться</a>';

        $x++;
        $klans = mysql_fetch_assoc($res);
    }
}

$result2 = mysql_query("SELECT geo.uin.uin, geo.uin.btl, geo.uin.map, geo.uin.nick FROM geo.uin RIGHT JOIN geo.friend ON geo.uin.uin = geo.friend.uin_2 WHERE geo.friend.uin = $row[uin] AND geo.uin.on_line >" . (time() - 300));

while ($row2 = mysql_fetch_row($result2))
{

    echo '<A href="info.php?uin=' . $row2[0] . '">•';
    echo $row2[3];
    if (!$row2[1] == 0)
    {
        echo "<font color=red> [b]</font>";
    }
    echo "<font color=green> [$row2[2]]</font></a>";
}

$result2 = mysql_query("SELECT geo.uin.uin, geo.uin.btl, geo.uin.map, geo.uin.nick FROM geo.uin RIGHT JOIN geo.enemy ON geo.uin.uin = geo.enemy.uin_2 WHERE geo.enemy.uin = $row[uin] AND geo.uin.on_line >" . (time() - 300));

while ($row2 = mysql_fetch_row($result2))
{
?>
<A href="info.php?uin=<?php
    echo $row2[0];
?>">• <?php
    echo $row2[3];
    if (!$row2[1] == 0)
    {
        echo "<font color=red> [b]</font>";
    }
    echo "<font color=green> [$row2[2]]</font></a>";
}

$tpl['uid'] = $row['uin'];
$tpl['name'] = $row['nick'];
$tpl['hp_now'] = $row['hp'];
$tpl['hp'] = $row['param_2'] * 6;

//уровни
$tpl['btl_l'] = lvl_p(1, $row['lev_1']) . "(" . $row['lev_1'] . ")";
$tpl['prz_l'] = lvl($row['uin'], 'lev_2') . "(" . $row['lev_2'] . ")";
$tpl['thn_l'] = lvl($row['uin'], 'lev_3') . "(" . $row['lev_3'] . ")";
$tpl['voj_l'] = lvl_d($row['lev_4'], 2) . "(" . $row['lev_4'] . ")";

//умения
$tpl['pis'] = lvl($row['uin'], 'gan_lev_1') . "($row[gan_lev_1])";
$tpl['avt'] = lvl($row['uin'], 'gan_lev_2') . "($row[gan_lev_2])";
$tpl['drb'] = lvl($row['uin'], 'gan_lev_3') . "($row[gan_lev_3])";
$tpl['vin'] = lvl($row['uin'], 'gan_lev_4') . "($row[gan_lev_4])";
$tpl['pul'] = lvl($row['uin'], 'gan_lev_5') . "($row[gan_lev_5])";
$tpl['grn'] = gren_lev($row['gan_lev_6']) . "(" . $row['gan_lev_6'] . ")";

$tpl['money_1'] = number_format($row['money_1'], 0, '.', '`');

include 'templates/ganjawars/pers.tpl'
?>
